package com.leetcode;

public class L0026 {
    public static void main(String[] args) {
        int[] arr={0,0,1,1,1,2,2,3,3,4};
        int n=removeDuplicates(arr);
        System.out.println(n);
    }
    public static int removeDuplicates(int[] nums) {
        if(nums==null)
            return 0;
        int i=0,j=1,count=0;
        while(j<nums.length){
            if(nums[i]!=nums[j]){
                nums[i+1]=nums[j];
                i++;
                j++;
            }else{
                j++;
                count++;
            }
        }
        return nums.length-count;
    }
}
